/**
 * Notes: 系统缓存实体 
 * Date: 2023-05-20 09:10:00 
 * Ver : CCMiniCloud Framework 2.0.6 ALL RIGHTS RESERVED BY CCLINUX0730 (wechat)
 */

const BaseModel = require('./base_model.js');

class CacheModel extends BaseModel {

}

/**
 * 删除记录(静态方法)
 * @param {*} where 条件
 * @param {*} isMulti 是否删除多条
 */
CacheModel.del = async function(where, isMulti = false) {
    try {
        const instance = new CacheModel(CacheModel.CL);
        return await instance.del(where);
    } catch (err) {
        console.error('删除缓存失败', err);
        return null;
    }
};

// 集合名
CacheModel.CL = BaseModel.C('cache');

CacheModel.DB_STRUCTURE = {
    _pid: 'string|true',
    CACHE_ID: 'string|true',
    CACHE_KEY: 'string|true|comment=缓存键',
    CACHE_VALUE: 'object|true|comment=缓存值',
    CACHE_EXPIRED: 'int|true|default=0|comment=过期时间戳',
    
    CACHE_ADD_TIME: 'int|true',
    CACHE_EDIT_TIME: 'int|true',
};

// 字段前缀
CacheModel.FIELD_PREFIX = "CACHE_";

module.exports = CacheModel; 